package com.example.xiaomi.Model.Service;

import com.example.xiaomi.Model.Controller.shoppingcartList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delete/cart")
public class delete_cart extends HttpServlet {
    shoppingcartList shoppingcartList = new shoppingcartList();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String data = req.getParameter("arr");
        String[] arr = data.split(",");
        int cid = Integer.parseInt(arr[arr.length-1]);
        for (int i = 0; i < arr.length-1; i++) {
            int uid = Integer.parseInt(arr[i]);
            shoppingcartList.doDelete(cid,uid);
        }
    }
}
